<?php

/**
 * @author thihien
 * @copyright 2011
 */

require_once('includes/general.php');
    if(!tep_db_checkDb()) die('ko ket noi dc csdl');
$content='';           

 $sql3='SELECT count(id) as count FROM `tbl_tin_tuc` where ma_danh_muc_tin_tuc=2 ';
  $kq3=tep_db_query($sql3);
  $item3=tep_db_fetch_array($kq3);
  //bat dau viet phan trang
 $display=3;// so san pham xuat hien tren mot trang
 $record=$item3['count'];//tong so san pham
  if($record>$display){
      $page=ceil($record/$display);
 }
 else{
      $page=1;
  }
  
 $curPage2 =isset($_GET['curPage2']) && (int)$_GET['curPage2']?$_GET['curPage2']:1;
 $start = ($curPage2 - 1)*$display;
 
  $sql4='select * from tbl_tin_tuc where ma_danh_muc_tin_tuc=2 limit '.$start.', '.$display.'';
 $kq4=tep_db_query($sql4);             
                 $content.='<div class="lamdep">
                        <div class="link"><a href="index.php?page=lamdepvasuckhoe">Làm đẹp và sức khỏe</a> >> <a href="#">Sức khỏe</a></div></br>
                         <h1>..:::.. Chuyên mục sức khỏe ..:::.. </h1>
                         <div class="block_lamdep">';
                                            
                                /**
  $sql1='select * from tbl_tin_tuc Where ma_danh_muc_tin_tuc =2 ';
                                $kq1=tep_db_query($sql1);*/

                             
                               while($item1=tep_db_fetch_array($kq4)){
                             $content.='<div class="chuyenmuclamdep">
                            <a href="index.php?matintuc='.$item1['id'].'&amp;maloaitintuc='.$item1['ma_danh_muc_tin_tuc'].'" ><img src="images/'.$item1['hinh_anh'].'" alt="'.$item1['hinh_anh'].'"/></a>
                             <h3><a href="index.php?matintuc='.$item1['id'].'&amp;maloaitintuc='.$item1['ma_danh_muc_tin_tuc'].'">'.$item1['tieu_de'].'</a></h3>
                           
                             </div>';
                              }
                              
                          $content.='
         <ul class="phantrang">';
       $content.='Trang:';
        $next=$curPage2 + 1;
        if($next > $page)
            $next = $page;
        $prev=$curPage2 - 1;
        if($prev < 1)
            $prev = 1;
        $current=($start/$display)+1;
        //hien thi phan trang prev
        if($current!=1){
           $content.='<li><a href="?page=suckhoe&amp;maloaitintuc=1&curPage2='.$prev.'">Previous</a></li>'; 
        }
         //hien thi trang
         for($i=1;$i<=$page;$i++){     
            if($current!=$i){
                $content.='<li><a href="?page=suckhoe&amp;maloaitintuc=1&curPage2='.$i.'">'.$i.'</a></li>'; 
             } 
            else
              {
                $content.='<li class="current"><a href="?page=suckhoe&amp;maloaitintuc=1&curPage2='.$i.'">'.$i.'</a></li>'; 
              }                       
         }
        //hien thi next
        if($current!=$page){
            $content.='<li><a href="?page=suckhoe&amp;maloaitintuc=1&curPage2='.$next.'">Next</a></li>';  
        }
        $content.=' </ul>';      
 

                        $content.=' <div class="clear"></div></div>
                    </div>';
    echo $content; 
?>